package com.example.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.entity.PmsCategory;
import com.example.entity.vo.PmsCategoryVo;
import com.example.mapper.PmsCategoryMapper;
import com.example.utils.TreeUtils01;
import com.example.utils.TreeUtils02;
import com.sun.org.apache.xerces.internal.util.EntityResolverWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * <p>
 * 商品三级分类 前端控制器
 * </p>
 *
 * @author fanbinbing
 * @since 2021-12-25
 */
@RestController
@RequestMapping("/pmsCategory")
public class PmsCategoryController {

    @Autowired
    private PmsCategoryMapper  pmsCategoryMapper;
    @GetMapping("/selectAllCategory")
    public Map<String,Object> selectAllCategory(){
        HashMap<String, Object> map = new HashMap<>();
        List<PmsCategoryVo> categories = pmsCategoryMapper.selectMap();
//        List<PmsCategoryVo> list = listWithTree();
//        List<PmsCategoryVo> list = TreeUtils01.buildByRecursive(categories);
        List<PmsCategoryVo> list = TreeUtils02.listWithTree(categories);
        map.put("code",0);
        map.put("msg","查询成功");
        map.put("data",list);
        return map;
    }

    
}

